package com.cloudptt.wp.ui.address.adapter;

import java.util.List;

import com.mcptt.config.model.McIdInfo;
import com.mcptt.db.model.GroupInfo;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;

public class ContactListAdapter extends BaseExpandableListAdapter {

	private Context context;
	private List<GroupInfo> groupList;
	private McIdInfo myMcInfo;
	
	public ContactListAdapter(Context ctx,List<GroupInfo> groupList,McIdInfo mcIdInfo) {
		// TODO Auto-generated constructor stub
		context = ctx;
		this.groupList = groupList;
		myMcInfo = mcIdInfo;
	}
	
	@Override
	public int getGroupCount() {
		// TODO Auto-generated method stub
		return groupList.size();
	}

	@Override
	public int getChildrenCount(int groupPosition) {
		// TODO Auto-generated method stub
		if(groupList == null || groupList.size() <= 0 
				|| groupList.get(groupPosition) == null || groupList.get(groupPosition).getMemberList() == null){
			return 0;
		}else{
			return groupList.get(groupPosition).getMemberList().size();
		}
	}

	@Override
	public Object getGroup(int groupPosition) {
		// TODO Auto-generated method stub
		if(groupList != null){
			return groupList.get(groupPosition);
		}else{
			return null;
		}
	}

	@Override
	public Object getChild(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		if(groupList != null && groupList.size() > 0 
				&& groupList.get(groupPosition) != null && groupList.get(groupPosition).getMemberList() != null){
			return groupList.get(groupPosition).getMemberList().get(childPosition);
		}
		return null;
	}

	@Override
	public long getGroupId(int groupPosition) {
		// TODO Auto-generated method stub
		return groupPosition;
	}

	@Override
	public long getChildId(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return childPosition;
	}

	@Override
	public boolean hasStableIds() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
			ViewGroup parent) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean isChildSelectable(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return false;
	}

}
